#include "PluginProcessor.h"
#include "PluginEditor.h"
#include <juce_audio_processors/juce_audio_processors.h>

//==============================================================================
AudioPluginAudioProcessorEditor::AudioPluginAudioProcessorEditor (AudioPluginAudioProcessor& p,juce::AudioProcessorValueTreeState& parameters)
    : AudioProcessorEditor (&p), processorRef (p)
{
    juce::ignoreUnused (processorRef);

    // addAndMakeVisible(button);
    // button.setButtonText("button");
    // button.onClick = [this]() { juce::AlertWindow::showMessageBoxAsync(juce::AlertWindow::InfoIcon, "button", "you clicked the button"); };
    // button.setBounds(getWidth() - 60, 0, 50, 24);

    // ui_reverb.setSize(200, 150);
    ui_reverb = new UI_Reverb("reverb",parameters);
    addAndMakeVisible (ui_reverb);

    // Make sure that before the constructor has finished, you've set the
    // editor's size to whatever you need it to be.
    setSize (800, 600);
    setResizable(true, true);
    // setResizeLimits(400, 300, 1600, 1200);
}

AudioPluginAudioProcessorEditor::~AudioPluginAudioProcessorEditor()
{
    // button.setLookAndFeel (nullptr);
    // ui_reverb.setLookAndFeel (nullptr);
    delete ui_reverb;
}

//==============================================================================
void AudioPluginAudioProcessorEditor::paint (juce::Graphics& g)
{
    // (Our component is opaque, so we must completely fill the background with a solid colour)
    g.fillAll (getLookAndFeel().findColour (juce::ResizableWindow::backgroundColourId));

    // g.setColour (juce::Colours::white);
    // g.setFont (15.0f);
    // g.drawFittedText ("Hello World!", getLocalBounds(), juce::Justification::centred, 1);
}

void AudioPluginAudioProcessorEditor::resized()
{
    // This is generally where you'll want to lay out the positions of any
    // subcomponents in your editor..

    auto area = getLocalBounds();

    ui_reverb->setBounds(area);
}
